﻿Imports TBCC.UtilityMobile
Public Class ParameterModifyClass

    ''' <summary>
    ''' 置位参数开始修改
    ''' </summary>
    ''' <param name="netID"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function EnterModify(ByVal netID As Byte) As Boolean
        ''获取当前参数修改变量
        'Dim b() As Short
        'b = COMHelper.Instance.Send4Short(netID, FunctionCode.WordWritableRead, 7061, 1)

        'If b Is Nothing OrElse b.Length <= 0 Then
        '    Return False
        'End If

        'If b(0) = 1 Then
        '    If ExitModify(netID) = False Then
        '        Return False
        '    End If
        'End If

        '参数修改变量置为1
        Dim result As Boolean
        Try

            result = COMHelper.Instance.Write(netID, FunctionCode.WordWrite, 7061, 1)

        Catch ex As Exception
            msg.ShowError(g_strReadError)
            Return False
        End Try
        'If result = False Then
        '    msg.ShowError("无法修改参数，请重试。")
        'End If

        Return result
    End Function


    ''' <summary>
    ''' 退出修改,复位参数修改变量
    ''' </summary>
    ''' <param name="netID"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function ExitModify(ByVal netID As Byte) As Boolean
        '参数修改变量置为0
        Dim result As Boolean

        Try

            result = COMHelper.Instance.Write(netID, FunctionCode.WordWrite, 7061, 0)

        Catch ex As Exception
            msg.ShowError(g_strReadError)
            Return False
        End Try

        Return result
    End Function


    ''' <summary>
    ''' 设置修改使能变量
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function SetModifyConfirm(ByVal netID As Byte) As Boolean
        Dim result As Boolean
        '参数修改使能变量；当参数备份区修改完毕后，使能确认；1=确认；
        Try

            result = COMHelper.Instance.Write(netID, FunctionCode.WordWrite, 7062, 1)

        Catch ex As Exception
            msg.ShowError(g_strReadError)
            Return False
        End Try

        If result = False Then
            'msg.ShowError("修改使能变量错误。")
        End If
        Return result
    End Function

End Class
